<!-- 收货方首页 -->
<template>
  <div class="gridContainer">
    <header-menu></header-menu>
    <template v-if="totalRecords > 0">
      <scroller lock-x scrollbar-y use-pullup :height="'-205'" :scroll-bottom-offst="100" @on-pullup-loading="getData" v-if="totalRecords > 0" :pullup-config="ScrollerConfig" ref="Scroller">
        <div>
          <div class="driver-list mb30" v-for="item in datas">
            <div class="list-header">
              <span class="f-l">业务单号：<i>{{item.BBillNo}}</i></span>
              <!--<em class="f-r orange">到货签收</em>-->
            </div>
            <div class="list-content">
                <dl class="displayflex">
                    <dt>
                       <div>
                          <i class="llse llse-cargo"></i>
                          <p>{{item.Pkgs}}件</p>
                        </div>
                    </dt>
                    <dd class="flex1">
                        <p>
                            <label>制单时间：</label>
                            <span>{{item.InputDate | time}}</span>
                        </p>
                        <p>
                            <label>供应单位：</label>
                            <span>{{item.SaleCorpName || '--'}}</span>
                        </p>
                        <p>
                            <label>送货联系人：</label>
                            <span>{{item.SendContacts}}-{{item.SendContactsTel}}</span>
                        </p>
                    </dd>
                </dl>
            </div>
            <div class="list-btn">
              <!-- <div class="carbtn" @click="conCheck(item.Guid)">详情</div> -->
              <div class="carbtn" @click="dispatch(item.Guid)">签收</div>
            </div>
          </div>

          <div class="noDate_page" v-if="totalRecords<=0">
            <div class="noDate_icon"><i class="iconfont icon-null"></i></div>
            暂无数据！
          </div>

          <p class="txt-bottom" v-if="noMore"><em class="txt">我是有底线的</em></p>
        </div>
      </scroller>
    </template>
    <div class="noDate_page" v-if="totalRecords==0">
        <div class="noDate_icon">
            <i class="iconfont icon-null"></i>
        </div>
        暂无数据！
    </div>
    <footer-menu></footer-menu>
  </div>
</template>
<script>
import headerMenu from '@/components/carrier/core/carrier-headermenu.vue';
import footerMenu from '@/components/carrier/core/carrier-footer.vue';
export default {
  data() {
    return {
      PageIndex: 1,
      PageSize: 8,

      datas: [],
      totalRecords: 0,
      ScrollerConfig: {
        content: "上拉加载",
        downContent: "上拉加载",
        height: 0,
        loadingContent: "加载中...",
        upContent: "上拉加载"
      },
      noMore: false,
    };
  },
  components: {
    headerMenu,
    footerMenu
  },
  watch: {
  },
  computed: {
    userinfo(){
      return localStorage.getItem('userinfo')?JSON.parse(localStorage.getItem('userinfo')):null;
    }
  },
  created() {
    this.getData();
  },
  methods: {
    // 获取列表信息
    getData: function() {
      var query = {
        PageIndex: this.PageIndex,
        PageSize: this.PageSize,
        BBillNo: self.BBillNo,
        DeliverGuid: this.userinfo.BelongGuid,
        StateList:[53,56]
      };
      this.Ajax.post("GetOrderlist", query).then((res) => {
        if (res.Datas && res.Datas.length > 0) {
          this.datas = this.datas.concat(res.Datas);
        }
        this.PageIndex++;
        this.totalRecords = res.TotalRecords;
        this.ScrollControl();
      });
    },


    //查看详情
    conCheck: function(BBillGuid, status) {
      this.$router.push({
        path: "carrdetail",
        query: {
          Guid: BBillGuid,
        }
      });
    },
    //签收列表
    dispatch: function(BBillGuid) {
      this.$router.push({
        path: "receiveconfirm",
        query:{
          Guid: BBillGuid
        }
      });
    },

    ScrollControl() {
      if (this.totalRecords <= this.PageSize) {
        this.ScrollerConfig.content = "";
        this.noMore = true;
        this.$nextTick(() => {
          this.$nextTick(() => {
            this.$refs.Scroller.disablePullup();
          });
        });
      }

      if (this.datas.length > 0 && this.$refs.Scroller) {
        this.$nextTick(() => {
          this.$nextTick(() => {
            this.$refs.Scroller.donePullup();
          });
        });
      }

      if (this.totalRecords == this.datas.length) {
        this.$nextTick(() => {
          this.$nextTick(() => {
            this.$refs.Scroller.disablePullup();
            this.noMore = true;
          });
        });
      }
    }
  },
};
</script>
